# from l0n0lnet.tcp import base_server
# from l0n0lnet import run

# class test_server(base_server):
#     def __init__(self, ip, port):
#         super().__init__(ip, port)

#     def on_session_connected(self, session_id):
#         print("链接", session_id)

#     def on_session_disconnected(self, session_id):
#         print("断开", session_id)

#     def on_session_read(self, session_id, data, size):
#         self.send_msg(session_id, data)
#         print(session_id, data, size)


# server = test_server(b'127.0.0.1', 1234)

# run()

# from l0n0lnet.tcp import *
# from l0n0lnet import *


# def on_session_connected(session_id):
#     print(session_id)


# def on_session_disconnected(session_id):
#     print(session_id)


# def on_session_read(session_id, data, size):
#     print(data)
#     send_message(session_id, data)
#     close_tcp(session_id)


# id = create_tcp_server("test", b"127.0.0.1", 1234, 1024)

# set_cb("test", "on_session_connected", on_session_connected)
# set_cb("test", "on_session_disconnected", on_session_disconnected)
# set_cb("test", "on_session_read", on_session_read)

# run()

import sys 
import os
import time

cur_file_path, filename = os.path.split(os.path.abspath(__file__))
sys.path.append(f"{cur_file_path}/../")

from l0n0lnet.tcp import *
from l0n0lnet import *

@handler_session_connected("test")
def on_session_connected(session_id):
    print("on_session_connected", session_id)
    # close_tcp(id)
    # session_read_size(session_id, 5)

@handler_session_disconnected("test")
def on_session_disconnected(session_id):
    print("on_session_disconnected", session_id)

@handler_session_read("test")
def on_session_read(session_id, data, size):
    # print(data)
    time.sleep(30)
    print("on_session_read", size)
    # session_read_until(session_id, b"123")
    # send_message(session_id, data)
    # close_tcp(session_id)

id = create_tcp_server("test", b"127.0.0.1", 1234, 1024)

run()